﻿using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks; 
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System.Net;
using System.Extensions; 
using System.Linq;

namespace Wfxin.SystemFramework.Filters
{
    public class PointsMallActionFilter: IAsyncActionFilter
    {
         
        private readonly ILogger _Logger = null;

        public PointsMallActionFilter(ILogger<PointsMallActionFilter> logger)
        { 
            _Logger = logger;
        }


        /// <summary>
        /// 验证Token
        /// </summary>
        /// <param name="context"></param>
        /// <param name="next"></param>
        /// <returns></returns>
        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            //ResposeInfo Res = new ResposeInfo();
            //string path = context.HttpContext.Request.Path.Value;
            //if (!path.StartsWith("/api"))
            //{ 
            //    _Logger.LogError("请求路径错误:{0}",path);
            //    Res = new ResposeInfo("fail", "请求路径不正确") { Code = 1 }; 
            //    context.Result = ActionResult.CreateResult(HttpStatusCode.BadRequest,Res.ToJson());
            //    return;
            //} 
            await next(); 
        }


    }
}
